/**
 * 
 */
package org.vsg.common.orm.hibernate;

import java.util.Calendar;
import java.util.Date;

/**
 * @author Bill Vison
 *
 */
public class DateTransExtensionFunction {
	
	
	public static  Date changeFirstTimeOfDate(Date date) {
		Calendar tmpCale = Calendar.getInstance();
		
		tmpCale.setTime(date);
		
		tmpCale.set(Calendar.HOUR_OF_DAY, 0);
		tmpCale.set(Calendar.MINUTE, 0);
		tmpCale.set(Calendar.SECOND, 0);
		tmpCale.set(Calendar.MILLISECOND, 0);
		
		return tmpCale.getTime();
	}
	
	public static Date changeNextFirstTimeOfDate(Date date) {
		Calendar tmpCale = Calendar.getInstance();
		
		tmpCale.setTime(date);
		tmpCale.add(Calendar.DATE, 1);
		
		tmpCale.set(Calendar.HOUR_OF_DAY, 0);
		tmpCale.set(Calendar.MINUTE, 0);
		tmpCale.set(Calendar.SECOND, 0);
		tmpCale.set(Calendar.MILLISECOND, 0);
		
		return tmpCale.getTime();		
	}
	
	public static Date changeLastTimeOfDate(Date date) {
		Calendar tmpCale = Calendar.getInstance();
		
		tmpCale.setTime(date);
		
		tmpCale.set(Calendar.HOUR_OF_DAY, 23);
		tmpCale.set(Calendar.MINUTE, 59);
		tmpCale.set(Calendar.SECOND, 59);
		tmpCale.set(Calendar.MILLISECOND, 999);
		return tmpCale.getTime();		
	}

}
